<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      //
      const obj = {
        0: "css",
        1: "js",
        2: "html",
        length: 3,
        a: 1,
        b: 2,
        [Symbol.iterator]() {
          // 迭代器
          let i = 0;
          return {
            next: () => {
              return { done: i > this.length - 1, value: [i, this[i++]] };
            },
          };
        },
      };
      for (const v of obj) {
        console.log(v);
      }

      // const it = obj[Symbol.iterator]();

      // console.log(it.next());
      // console.log(it.next());
      // console.log(it.next());
      // console.log(it.next());
    </script>
  </body>
</html>
